package com.ita.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;


/**
 * 客户端用户
 * @author WUJA13
 *
 */
@Entity
@Table(name = "c_user")
@GenericGenerator(name="uu", strategy="uuid")
//@SequenceGenerator(name="seq1", sequenceName="seq01", initialValue=1, allocationSize=1)
public class User implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	///id
	@Id
	@Column(name="id",length=36)
	//@Column(name="id")
	@GeneratedValue(generator="uu")
	private String id;
	//name
	@Column(name = "name", nullable = false, length = 40, insertable = true/* false表示不能插入 */, updatable = true/* 可被更新 */, unique = true)
	private String name;
	//psd
	@Column(name = "psd",nullable = false, length = 30,insertable=true)
	@JsonIgnore
	private String psd;

    //reg_time
//	@Temporal(TemporalType.DATE)
//	private Date regTime;
	
	@OneToMany(mappedBy="user", cascade=CascadeType.REMOVE,fetch=FetchType.EAGER)
	private Set<Address> addrs = new HashSet<Address>();

	public User() {
		super();
	}

	public User(String id, String name, String psd) {
		super();
		this.id = id;
		this.name = name;
		this.psd = psd;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPsd() {
		return psd;
	}

	public void setPsd(String psd) {
		this.psd = psd;
	}


    
	public Set<Address> getAddrs() {
		return addrs;
	}

	public void setAddrs(Set<Address> addrs) {
		this.addrs = addrs;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", name=" + name + ", psd=" + psd
				+ ", addrs=" + addrs + "]";
	}
    
	
}
